﻿using System;
using System.Collections.Generic;
namespace Model
{
	public class RepeatedSound
	{
		public string Name { get; set; }
		public string NameOfXmlParameterForVolume { get; set; }
		public string NameOfXmlParameterForFrequency { get; set; }
		public string NameOfXmlParameterForEcho { get; set; }
		public double ValueOfXmlParameterForVolume { get; set; }
		public double ValueOfXmlParameterForFrequency { get; set; }
		public double ValueOfXmlParameterForEcho { get; set; }
		public double ValueOfXmlParameterToEnableEchoFrom { get; set; }
		DependenceFunction dependenceFunctionForVolume = new DependenceFunction();
		DependenceFunction dependenceFunctionForFrequency = new DependenceFunction();

		public double Volume
		{
			get
			{
				try
				{
					double volume = dependenceFunctionForVolume.GetY(ValueOfXmlParameterForVolume);
					return volume;
				}
				catch (Exception e)
				{
					return 0;
				}
			}
		}

		public double Frequency
		{
			get
			{
				try
				{
					double frequency = dependenceFunctionForFrequency.GetY(ValueOfXmlParameterForFrequency);
					return frequency;
				}
				catch (Exception e)
				{
					return 0;
				}
			}
		}
		
		public SortedList<double, double> TableOfValuesForVolume
		{
			get { return dependenceFunctionForVolume.GetTableOfValues(); }
			set { dependenceFunctionForVolume.SetTableOfValues(value); }
		}

		public SortedList<double, double> TableOfValuesForFrequency
		{
			get { return dependenceFunctionForFrequency.GetTableOfValues(); }
			set { dependenceFunctionForFrequency.SetTableOfValues(value); }
		}
		
		public bool Echo 
		{
			get 
			{
				if (ValueOfXmlParameterForEcho >= ValueOfXmlParameterToEnableEchoFrom)
				{
					return true;
				}
				else return false;
			} 
		}

		public string SoundFileLocation { get; set; }
	}
}
